package com.lb.jwitter.action;


import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import java.util.Map; 
import org.springframework.test.context.ContextConfiguration; 
import com.lb.jwitter.service.TblQuyenChiTietService; 
import com.lb.jwitter.service.TblTaiKhoan; 
import com.opensymphony.xwork2.ActionContext; 
import com.lb.jwitter.util.ApplicationContextProvider; 
import java.util.ArrayList;
import com.lb.jwitter.service.ConditionReport; 
 import com.opensymphony.xwork2.Action; 
import com.lb.jwitter.service.TblQLDTTXAChuongTrinhHoc;
import com.lb.jwitter.service.TblQLDTTXAChuongTrinhHocService;
import com.lb.jwitter.service.TblQLDTTXADMKhoa;
import com.lb.jwitter.service.TblQLDTTXADMKhoaService;

import com.lb.jwitter.service.TblQLDTTXAChuongTrinhHocChiTiet;
import com.lb.jwitter.service.TblQLDTTXAChuongTrinhHocChiTietService;

import com.lb.jwitter.service.TblQLDTTXAHocKy;
import com.lb.jwitter.service.TblQLDTTXAHocKyService;

import com.lb.jwitter.service.TblQLDTTXAMonHoc;
import com.lb.jwitter.service.TblQLDTTXAMonHocService;

 /** 
 * @author QUOCVIET  
 * 
 */ 


@ContextConfiguration(locations="classpath:beans.xml") 
public class TblQLDTTXAChuongTrinhHocEditFormAction{
    private int id; 
    public void setId(int id) {
       this.id = id;
 }

    public int getId() {
       return id;
 }

    private TblQLDTTXAChuongTrinhHoc tblQLDTTXAChuongTrinhHoc; 
    public TblQLDTTXAChuongTrinhHoc getTblQLDTTXAChuongTrinhHoc() { 
        return tblQLDTTXAChuongTrinhHoc; 
    } 
    private TblQLDTTXAChuongTrinhHocService tblQLDTTXAChuongTrinhHocService; 

    private List<TblQLDTTXADMKhoa> tblQLDTTXADMKhoas; 
    public List<TblQLDTTXADMKhoa>  getTblQLDTTXADMKhoas(){ 
              return tblQLDTTXADMKhoas; 
     } 

    private TblQLDTTXADMKhoaService tblQLDTTXADMKhoaService; 

    private List<TblQLDTTXAChuongTrinhHocChiTiet> tblQLDTTXAChuongTrinhHocChiTiets; 
    public List<TblQLDTTXAChuongTrinhHocChiTiet>  getTblQLDTTXAChuongTrinhHocChiTiets(){ 
              return tblQLDTTXAChuongTrinhHocChiTiets; 
     } 

    private TblQLDTTXAChuongTrinhHocChiTietService tblQLDTTXAChuongTrinhHocChiTietService; 

    private List<TblQLDTTXAHocKy> tblQLDTTXAHocKys; 
    public List<TblQLDTTXAHocKy>  getTblQLDTTXAHocKys(){ 
              return tblQLDTTXAHocKys; 
     } 

    private TblQLDTTXAHocKyService tblQLDTTXAHocKyService; 

    private List<TblQLDTTXAMonHoc> tblQLDTTXAMonHocs; 
    public List<TblQLDTTXAMonHoc>  getTblQLDTTXAMonHocs(){ 
              return tblQLDTTXAMonHocs; 
     } 

    private TblQLDTTXAMonHocService tblQLDTTXAMonHocService; 

  private TblTaiKhoan taiKhoanDangNhap; 
 public TblTaiKhoan getTaiKhoanDangNhap() { 
     return taiKhoanDangNhap; 
 } 
 public void setTaiKhoanDangNhap(TblTaiKhoan taiKhoanDangNhap) { 
     this.taiKhoanDangNhap = taiKhoanDangNhap; 
 } 
 private TblQuyenChiTietService tblQuyenChiTietService;
	 @Autowired // Injected by Spring 
     ApplicationContextProvider contextProvider; 
    public String execute() throws Exception 
   { 
       try{ 
     Map session = ActionContext.getContext().getSession();
     taiKhoanDangNhap =  (TblTaiKhoan) session.get("taiKhoan");
     if( taiKhoanDangNhap == null) return "noprivilege";
    ApplicationContext context = ApplicationContextProvider.getApplicationContext(); 
    tblQuyenChiTietService = (TblQuyenChiTietService) context.getBean("tbl_Quyen_ChiTietClient"); 
    if(!tblQuyenChiTietService.checkRight(taiKhoanDangNhap.getMaNhomQuyen().getId(), "tbl_QLDTTXA_ChuongTrinhHoc", "sua")){ 
        return "noprivilege"; 
    }        tblQLDTTXAChuongTrinhHocService = (TblQLDTTXAChuongTrinhHocService) context.getBean("tbl_QLDTTXA_ChuongTrinhHocClient"); 
        tblQLDTTXADMKhoaService = (TblQLDTTXADMKhoaService) context.getBean("tbl_QLDTTXA_DM_KhoaClient"); 

        tblQLDTTXAChuongTrinhHocChiTietService = (TblQLDTTXAChuongTrinhHocChiTietService) context.getBean("tbl_QLDTTXA_ChuongTrinhHoc_ChiTietClient"); 

        tblQLDTTXAHocKyService = (TblQLDTTXAHocKyService) context.getBean("tbl_QLDTTXA_HocKyClient"); 

        tblQLDTTXAMonHocService = (TblQLDTTXAMonHocService) context.getBean("tbl_QLDTTXA_MonHocClient"); 

        tblQLDTTXAChuongTrinhHoc = tblQLDTTXAChuongTrinhHocService.gettblQLDTTXAChuongTrinhHoc(new Long(id)); 
        tblQLDTTXADMKhoas = tblQLDTTXADMKhoaService.findAlltblQLDTTXADMKhoa(0, 0);

   List<ConditionReport> cons = new ArrayList<ConditionReport>(); 
   if (id != 0) 
   { 
       ConditionReport con = new ConditionReport(); 
       con.setCol("chuongTrinhHocId.id"); 
       con.setValue1(new Long(id)); 
       con.setOperator("eq"); 
       cons.add(con); 
   } 
   tblQLDTTXAChuongTrinhHocChiTiets = tblQLDTTXAChuongTrinhHocChiTietService.findtblQLDTTXAChuongTrinhHocChiTietByCondition(cons, 0, 0); 
      tblQLDTTXAHocKys =       tblQLDTTXAHocKyService.findAlltblQLDTTXAHocKy(0, 0); 
      tblQLDTTXAMonHocs =       tblQLDTTXAMonHocService.findAlltblQLDTTXAMonHoc(0, 0); 
        return Action.SUCCESS; 
      } 
      catch(Exception e){ 
      System.out.println("Loi EditForm tbl_QLDTTXA_ChuongTrinhHoc Action"); 
     e.printStackTrace(); 
    return Action.ERROR; 
 } 
 } 
 } 
 
